#ifndef _HammersleySampler_H_
#define _HammersleySampler_H_

#pragma once
#include "Sampler.h"

class HammersleySampler : public Sampler {
private:
	Double phi(int j) {
		Double x = 0.0;
		Double f = 0.5;

		while (j) {
			x += f * Double(j % 2);
			j /= 2;
			f *= 0.5;
		}

		return x;
	}
	void generateSamples() {
		samples.reserve(numSets * numSamples);

		for (int p = 0; p < numSets; p++)
			for (int j = 0; j < numSamples; j++) {
				samples.emplace_back(Double(j) / numSamples, phi(j));
			}
	}

public:
	HammersleySampler(int numSamples) : Sampler(numSamples) {}
	HammersleySampler(int numSamples, int numSets) : Sampler(numSamples, numSets) {}
	~HammersleySampler() {}
};

#endif // _HammersleySampler_H_